package com.jz.common;

import com.jz.cost.enums.CurrencyEnum;
import com.jz.cost.enums.JizhangEnum;
import com.jz.cost.enums.StatusEnum;
import com.jz.cost.mapper.CostMapper;
import com.jz.cost.model.TaxVo;
import com.jz.cost.model.XialaVo;
import com.jz.cost.service.CostService;
import com.jz.storeroomclass.service.StoreroomService;
import com.jz.util.ResultBuildVo;
import com.jz.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by WISE on 2022-01-06.
 */
@RestController
@CrossOrigin
public class CommonController {

    @Autowired
    private CostMapper costMapper;
    @Autowired
    private CostService costService;
    @Autowired
    private StoreroomService storeroomService;


@GetMapping("materialCostPrice/queryAllTaxType")
    public ResultVo queryAllTaxType(){

    List<TaxVo> taxVoList = costMapper.queryAllTaxType();

    return ResultBuildVo.success(taxVoList);
}
/*
当传多个集合，通过传map或者对象
集合：
* 当前状态：statusList  币别：money  价格分类：jizhang
* 字段：value:value label:label
* url:  metadata/getPullDownList
* POST
* */

@PostMapping("metadata1/getPullDownList")
    public ResultVo getPullDownList(){

    Map<String,List<XialaVo>> map = new HashMap<>();
    //1.当前状态
    List<XialaVo> statusList = new ArrayList<>();
        for (StatusEnum priceEnum : StatusEnum.values()) {
            XialaVo priceVo = new XialaVo(priceEnum.getStatus(), priceEnum.getStatusName());
            statusList.add(priceVo);
        }
    map.put("statusList",statusList);
//    //2.币别
    List<XialaVo> currencyList = new ArrayList<>();
        for (CurrencyEnum priceEnum : CurrencyEnum.values()) {
            XialaVo priceVo = new XialaVo(priceEnum.getStatus(), priceEnum.getStatusName());
            currencyList.add(priceVo);
        }
    map.put("money",currencyList);
    //3.价格分类
    List<XialaVo> priceList = new ArrayList<>();
        for (JizhangEnum priceEnum : JizhangEnum.values()) {
            XialaVo priceVo = new XialaVo(priceEnum.getStatus(), priceEnum.getStatusName());
            priceList.add(priceVo);
        }
    map.put("jizhang",priceList);

    return ResultBuildVo.success(map);
}
//    //法人下拉框
    @GetMapping("legalPerson1/ofCurrentUser")
    public ResultVo ofCurrentUser() {

        Integer userId = 1;

        return costService.queryByUserId(userId);
    }
   //库房标识下拉框
    @GetMapping("warehouse/queryWarehouseTagList")
    public ResultVo queryWarehouseTagList() {

        return storeroomService.queryWarehouseTagList();
    }
    //库区属性下拉框
    @GetMapping("storageSection/queryBusinessAttribute")
    public ResultVo queryBusinessAttribute() {

        return storeroomService.queryBusinessAttribute();
    }
    //库房信息下拉框
    @GetMapping("storageSection/queryWareHouse")
    public ResultVo queryWareHouse() {

        return storeroomService.queryWareHouse();
    }





}
